<template>
  <nav id="sidebar">
    <ul>
      <li class="yun">
        <img src="@/../public/CC_Logo.png" width="50px" alt="Logo">
      </li>
      <span class="yunmeng">云萌工作室</span>
      <li>
        <router-link to="/cash-flow-statement" active-class="active" @click="highlightLink">
          数据可视化界面
        </router-link>
      </li>
      <li>
        <router-link to="/sales-forecast" active-class="active" @click="highlightLink">
          每月销售预测
        </router-link>
      </li>
      <li>
        <router-link to="/sales-plan" active-class="active" @click="highlightLink">
          销售成本和计划
        </router-link>
      </li>
      <li class="dropdown">

          <li>
            <router-link to="/Income" active-class="active" @click="highlightLink">
              现金流入
            </router-link>
          </li>
          <li>
            <router-link to="/Outcome" active-class="active" @click="highlightLink">
              现金流出
            </router-link>
          </li>
        
      </li>
    </ul>
  </nav>
</template>

<script>
export default {
  name: 'AppSidebar',
  methods: {
    highlightLink(event) {
      const links = document.querySelectorAll('nav ul a');
      links.forEach(link => link.classList.remove('active'));
      event.target.classList.add('active');
    }
  }
};
</script>

<style scoped>
body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  background-color: #f0f0f0;
}
nav {
  background-color: #333;
  padding: 0px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 170px;
  transform: translateX(-250px);
  transition: transform 0.3s ease;
  z-index: 1000;
}
nav ul {
  padding: 0;
  margin: 0;
  list-style-type: none;
}
nav ul li {
  margin: 0;
}
nav ul a {
  display: block;
  padding: 16px;
  text-decoration: none;
  font-size: 18px;
  color: rgb(227, 227, 227);
}
nav ul a:hover {
  background-color: #666;
}
.menu-button-container {
  position: fixed;
  top: 20px;
  right: -40px;
  z-index: 1100;
  transition: transform 0.3s ease;
}
.menu-button {
  background-color: #909399;
  color: #fff;
  padding: 10px;
  font-size: 18px;
  cursor: pointer;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 5px;
  text-align: center;
  line-height: 20px;
}
.content {
  padding: 20px;
  margin-left: 60px;
  transition: margin-left 0.3s ease;
  position: relative;
}
.content.shifted {
  margin-left: 310px;
}
@media (max-width: 768px) {
  nav {
    width: 200px;
    transform: translateX(-200px);
  }
  .content.shifted {
    margin-left: 260px;
  }
}
@media (max-width: 480px) {
  nav {
    width: 150px;
    transform: translateX(-150px);
  }
  .content.shifted {
    margin-left: 210px;
  }
}
.logo {
  color: var(--color-white);
  font-size: 30px;
}
.logo span {
  color: var(--color-primary);
}
.yun {
  margin-left: 0px;
}
.yunmeng {
  margin-left: 5px;
  color: #f4f4f6;
  font-family: 楷体;
}
#start {
  margin-left: 50% 50%;
}
.dropdown {
  position: relative;
}
.dropdown-content {
  display: none;
  position: relative;
  background-color: #444;
  min-width: 170px;
  z-index: 1;
}
.dropdown-content li {
  margin: 0;
}
.dropdown-content a {
  padding: 16px;
  text-decoration: none;
  font-size: 18px;
  color: rgb(227, 227, 227);
  display: block;
}
.dropdown-content a:hover {
  background-color: #666;
}
.dropdown:hover .dropdown-content {
  display: block;
}
</style>
